<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp" %>
<%@ include file="/commons/validation.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${key.charge_adjust_title}</title>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript">
var otherValidate = true;
function ajaxSubmit(){
	var isTrue=$('adjustForm').fireEvent("onSubmit");
    if(isTrue && otherValidate){
        var url = "${ctx}/charge_cashieringAction.do?method=addAdjustFeeRate";
        var param = Form.serialize('adjustForm');
        new Ajax.Request(url,{method: 'post',parameters :param ,onSuccess : showResponse});
	}
}
function showResponse(response){
	if(response.responseText.indexOf("true")!=-1 ){
	    var obj = findFrame("lateFeeListFrame");
	    windowClose();
	    obj.parent.refresh(0.00);
	    obj.parent.refreshChargetDetailList();
	    var cc = response.responseText.split(",");
	    obj.parent.totalAmt=cc[1];
	    obj.parent.balance=cc[2];
    }
    else
       ajaxSubmitException(response.responseText);
}
function getLateFeeRate(thiz){
	 var id = thiz.options[thiz.selectedIndex].value;
	 document.getElementById("tempRate").value="";
	 if(id == ""){
		 document.getElementById('tselectChargeItem').innerHTML="";
     }else{
		 var url = "${ctx}/charge_cashieringAction.do?method=getLateFeeRateBy&houseId=${houseId}&businessId="+id;
		 new Ajax.Request(url,{method: 'post',onSuccess : showRateResponse});
     }
}
function showRateResponse(response){
	if(response.responseText != "false"){
		document.getElementById('rate').value = response.responseText;
		document.getElementById('tselectChargeItem').innerHTML=response.responseText+"%";
	}
}
function compareDate(thiz,other,self){
	var z = document.getElementById(thiz);
	var t = document.getElementById(other);
	var beginDate = z.options[z.selectedIndex].value;
	var endDate = t.options[t.selectedIndex].value;
	if(beginDate == "" || endDate == ""){
		return;
	}
	var begin = new Date();
	var end = new Date();
	begin.setFullYear(beginDate.substr(0,4));
	begin.setMonth(beginDate.substr(4));
	end.setFullYear(endDate.substr(0,4));
	end.setMonth(endDate.substr(4));
	if(begin.getTime()-end.getTime()>0){
		if(self.name == thiz){
			validationAlert(self,true,"开始周期必须小于等于结束周期");
			otherValidate = false;
		}if(self.name ==  other){
			validationAlert(self,true,"结束周期必须大于等于开始周期");
			otherValidate = false;
		}
	}
	else{
		if(document.getElementById("advice-"+thiz) != null){
		document.getElementById("advice-"+thiz).style.display = 'none';
		otherValidate = true
		}if(document.getElementById("advice-"+other)!=null){
		document.getElementById("advice-"+other).style.display = 'none';
		otherValidate = true
		}
	}
}
</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">按滞纳金比率调整</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td border="0" cellspacing="0" cellpadding="0" class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color">
        <form name="adjustForm" method="post" action="${ctx}/charge_cashieringAction.do?method=addAdjustFeeRate" class="required-validate">
        <input type="hidden" name="rate" value="0.00">
        <input type="hidden" name="accountId" value="${accountId}">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color" id="sssss">
            <tr>
              <td class="aux_intable_td1" style="width:'30%';">周期范围：</td>
              <td class="aux_intable_require" style="width:'70%';">
                <pms:unitedSelect id="startPeriod"
						name="startPeriod"
                      		optionLabel="period"
                      		optionValue="period"
                      		selectText="请选择..."
                      		dataList="${periodList}"
                      		className="select-one-required"
                      		onChange="compareDate('startPeriod','endPeriod',this)"
                      		style="width:110px;"
                      		>
				</pms:unitedSelect>
				 到
              <pms:unitedSelect id="endPeriod"
						name="endPeriod"
                      		optionLabel="period"
                      		optionValue="period"
                      		selectText="请选择..."
                      		dataList="${periodList}"
                      		className="select-one-required"
                      		onChange="compareDate('startPeriod','endPeriod',this)"
                      		style="width:110px;"
                      		>
				</pms:unitedSelect>             </td>
              </tr>
			<tr>
              <td class="aux_intable_td1">来源交易：</td>
              <td class="aux_intable_require">
                <pms:unitedSelect
						name="bizCodeId"
                      		optionLabel="itemName"
                      		optionValue="businessCodeId"
                      		selectText="请选择"
                      		className="select-one-required"
                      		onChange="getLateFeeRate(this)"
                      		dataList="${chargeItemList}"
                      		style="width:110px;"
                      		>
				</pms:unitedSelect>             </td>
              </tr>
             <tr>
              <td class="aux_intable_td1">系统预设比率：</td>
              <td class="aux_intable_td2" id="tselectChargeItem"></td>
             </tr>
			 <tr>
              <td class="aux_intable_td1">调整后比率：</td>
              <td class="aux_intable_require"><input name="tempRate" type="text" class="required float-right integer-decimal-range-8-2 less-equals-than-rate" maxlength="8" size="6" style="text-align:right;width:110px;"  value="" afterInsert="tip">%<span id="tip"></span> </td>
            </tr>
            <tr>
              <td valign="top" class="aux_intable_td1">交易摘要：</td>
              <td valign="top" class="aux_intable_require_more"><textarea name="tranDigest" class="required max-length-500" cols="25" rows="4" ></textarea></td>
              </tr>

        </table></form></td>
      </tr>
    </table></td>
  </tr>
  <tr>

    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0" onclick="ajaxSubmit();">
            <tr>
              <td class="buttonOffLeft" id="btn1_61"></td>
              <td class="buttonOffMiddle" id="btn1_62"  onMouseOver="btn_change_over(6)" onMouseOut="btn_change_out(6)" onBlur="btn_change(6)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom">保 存</td>
              <td class="buttonOffRight" id="btn1_63"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_71"></td>
              <td class="buttonOffMiddle" id="btn1_72" onClick="windowClose();" onMouseOver="btn_change_over(7)" onMouseOut="btn_change_out(7)" onBlur="btn_change(7)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom">关 闭</td>
              <td class="buttonOffRight" id="btn1_73"></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <p>&nbsp;</p></td>
  </tr>
</table>
</body>
</html>